<template>
	<view class="my-container">
		<!-- 顶部用户信息区域 -->
		<view class="user-info" @click="goToEditProfile">
			<view class="user-avatar-wrapper">
				<u-avatar :src="userInfo.avatar" size="120" mode="aspectFill"></u-avatar>
				<view class="avatar-edit">
					<u-icon name="camera" color="#fff" size="20"></u-icon>
				</view>
			</view>
			<view class="user-detail">
				<view class="name-row">
					<text class="user-name">{{userInfo.name || '彩虹小白马'}}</text>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
				<text class="user-signature">{{userInfo.signature || '点击编辑个性签名'}}</text>
			</view>
		</view>

		<!-- 功能列表 -->
		<view class="function-list">
			<view class="function-item" @click="goToPage('倾诉记录')">
				<view class="item-left">
					<u-icon name="list" color="#4a90e2" size="22"></u-icon>
					<text class="function-text">我的倾诉记录</text>
				</view>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>

			<view class="function-item" @click="goToPage('我的关注')">
				<view class="item-left">
					<u-icon name="star" color="#4a90e2" size="22"></u-icon>
					<text class="function-text">我的关注</text>
				</view>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>

			<view class="function-item" @click="goToPage('反馈与建议')">
				<view class="item-left">
					<u-icon name="heart" color="#4a90e2" size="22"></u-icon>
					<text class="function-text">反馈与建议</text>
				</view>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>

			<view class="function-item" @click="handleContactCustomerService">
				<view class="item-left">
					<u-icon name="order" color="#4a90e2" size="22"></u-icon>
					<text class="function-text">联系客服</text>
				</view>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>


		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {
					avatar: 'https://img2.baidu.com/it/u=2925226694,390810694&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
					name: '微信用户',
					signature: '个性签名'
				}
			}
		},
		methods: {
			goToPage(pageName) {
				console.log(`跳转到${pageName}页面`);
				// 这里可以根据实际需求添加跳转逻辑

				// 示例：
				if (pageName === '倾诉记录') {
					uni.navigateTo({
						url: '/pages/My/personal'
					});
				} else if (pageName === '我的关注') {
					uni.navigateTo({
						url: '/pages/My/attentionlist'
					});
				} else if (pageName === '反馈与建议') {
					uni.navigateTo({
						url: '/pages/My/feedback'
					});
				}
				// 其他页面跳转...
			},
			// 新增联系客服处理方法
			handleContactCustomerService() {
				uni.showModal({
					title: '联系客服',
					content: '是否拨打客服电话 400-123-4567？',
					confirmText: '拨打',
					cancelText: '取消',
					success: (res) => {
						if (res.confirm) {
							uni.makePhoneCall({
								phoneNumber: '4001234567' // 替换为实际客服电话
							});
						}
					}
				});
			},
			goToEditProfile() {
				uni.navigateTo({
					url: '/pages/user/usermsg'
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my-container {
		display: flex;
		flex-direction: column;
		background-color: #fff;
	}

	.user-info {
		display: flex;
		align-items: center;
		padding: 40rpx 30rpx;
		background: linear-gradient(135deg, #f0f9ff 0%, #e6f4ff 100%);
		border-bottom-left-radius: 20rpx;
		border-bottom-right-radius: 20rpx;
		margin-bottom: 20rpx;
		position: relative;

		.user-avatar-wrapper {
			position: relative;
			margin-right: 30rpx;

			.avatar-edit {
				position: absolute;
				right: 0;
				bottom: 0;
				width: 40rpx;
				height: 40rpx;
				background-color: rgba(74, 144, 226, 0.7);
				border-radius: 50%;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}

		.user-detail {
			display: flex;
			flex-direction: column;
			flex: 1;

			.name-row {
				display: flex;
				align-items: center;
				margin-bottom: 10rpx;

				.user-name {
					font-size: 38rpx;
					font-weight: bold;
					color: #333;
					margin-right: 10rpx;
				}
			}

			.user-signature {
				font-size: 28rpx;
				color: #666;
				max-width: 80%;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
		}
	}

	.function-list {
		background-color: #fff;
		border-radius: 16rpx;
		margin: 0 20rpx 20rpx;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
		overflow: hidden;

		.function-item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 30rpx;
			border-bottom: 1rpx solid #f0f0f0;

			&:last-child {
				border-bottom: none;
			}

			.item-left {
				display: flex;
				align-items: center;
			}

			.function-text {
				margin-left: 20rpx;
				font-size: 30rpx;
				color: #333;
			}
		}
	}

	.bottom-nav {
		display: flex;
		justify-content: space-around;
		align-items: center;
		padding: 10rpx 0;
		background-color: #fff;
		box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);

		.nav-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 10rpx 0;

			.nav-text {
				font-size: 24rpx;
				color: #999;
				margin-top: 4rpx;
			}

			&.active {
				.nav-text {
					color: #4a90e2;
				}
			}
		}
	}
</style>